{% extends 'base.html' %}

{% block title %}
    CheckOut
{% endblock %}

{% block content %}
    <h1>Checkout</h1>

    <div class="order-info">
        <h3>Your order</h3>
        <ul>
            {% for item in cart %}
                <li>
                    {{ item.quantity }} X {{ item.product.name }}
                    <span>${{ item.total_price|floatformat:"2" }}</span>
                </li>
            {% endfor %}
        {% if cart.coupon %}
            <li>
            "{{ cart.coupon.code }}" ({{ cart.coupon.discount }}% off)
            <span>-${{ cart.get_discount|floatformat:"2" }}</span>
            </li>
        {% endif %}
        </ul>
        <p>Total:${{ cart.get_total_price_after_discount|floatformat:"2" }}</p>
    </div>

    <form action="." method="post" class="order-form" novalidate>
        {{ form.as_p }}
        <p><input type="submit" value="Place order"></p>
        {% csrf_token %}
    </form>
{% endblock %}